package com.dlnu.shoping.shopping.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.dlnu.shoping.shopping.common.Result;
import com.dlnu.shoping.shopping.entity.Orderlist;
import com.dlnu.shoping.shopping.mapper.OrderDao;
import com.dlnu.shoping.shopping.service.OrderService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.sql.Timestamp;

@Service
public class OrderServiceImpl implements OrderService {
    @Resource
    private OrderDao orderDao;

    @Override
    public Result search(Integer userId) {
        return new Result(orderDao.search(userId));
    }

    @Override
    public Result add(Integer userId, Integer proId, Integer addressId) {
        Orderlist order = new Orderlist();
        order.setUserId(userId);
        order.setProId(proId);
        order.setAddressId(addressId);
        order.setCreateTime(new Timestamp(System.currentTimeMillis()));
        System.out.println(order);
        orderDao.insert(order);
        return Result.SUCCESS;
    }
}
